<?php

if (!defined('BASEPATH'))
    exit('Sem permissao de acesso direto ao Script.');


class Atividades_model extends CI_Model {
     private $tabela;
    
    function __construct() {
        parent::__construct();
        
        $this->tabela = 'servico';
    }
    
    function get_all_aberta(){
        
        $this->db->select('s.*,st.nome as nome_s');
        
        $this->db->from($this->tabela.' as s');
        $this->db->join('setor AS st', 's.setor_id = st.id', 'LEFT'); 
        $this->db->where('s.progresso','1');
        $this->db->order_by('s.id','desc');
        $this->db->order_by('s.titulo');
        $this->db->limit('5','0');
        
        $servico = $this->db->get();
        
        if($servico->num_rows() > 0){
            
            return $servico->result();
        }
        else {
            
            return array();
        }
    }
    function get_all_progresso(){
        
        $this->db->select('s.*,st.nome as nome_s');
        
        $this->db->from($this->tabela.' as s');
        $this->db->join('setor AS st', 's.setor_id = st.id', 'LEFT');  
        $this->db->where('s.progresso','2');
        $this->db->order_by('s.id','desc');
        $this->db->order_by('s.titulo');
        $this->db->limit('5','0');
        
        $servico = $this->db->get();
        
        if($servico->num_rows() > 0){
            
            return $servico->result();
        }
        else {
            
            return array();
        }
    }
    
    
    function get_all_fechada(){
        
        $this->db->select('s.*,st.nome as nome_s');
        
        $this->db->from($this->tabela.' as s');
        $this->db->join('setor AS st', 's.setor_id = st.id', 'LEFT'); 
        $this->db->where('s.progresso','3');
        $this->db->order_by('s.id','desc');
        $this->db->order_by('s.titulo');
        $this->db->limit('5','0');
        
        $servico = $this->db->get();
        
        if($servico->num_rows() > 0){
            
            return $servico->result();
        }
        else {
            
            return array();
        }
    }
    
    
    

}
